const env_dev = 'dev';
const env_prod = 'prod';
const env_test = 'test';
const env_uat = 'uat';

function isDev(env){
    return env_dev === env;
}

//typeof 返回的是字符串，有六种可能："number"、"string"、"boolean"、"object"、"function"、"undefined"

function isUndefined(obj){
    return typeof (obj) == "undefined";
}
function  isNull(obj){
    return !obj && typeof (obj) != "undefined" && obj !== 0;
}
function isNullOrUndefined(obj){
    return obj === undefined || obj == null;
}
function isNullOrUndefinedOrNaN(obj){
    return !obj;
}
function isBlank(str){
    if (isNullOrUndefinedOrNaN(str)){
        return true;
    }
    return str.trim() === '';
}
function isNotBlank(str){
    return !isBlank(str);
}


/**
 * 返回结果是否正确
 *
 * @param data
 * @returns {boolean}
 */
function successData(data){
    return data.code === 2000;
}



let CSRF_COOKIE_NAME = null;
function getCsrfCookieName(){
    if (CSRF_COOKIE_NAME == null){
        CSRF_COOKIE_NAME = $("meta[name='csrf_cookie_name']").attr("content");
        if (isBlank(CSRF_COOKIE_NAME)){
            CSRF_COOKIE_NAME = 'XSRF-TOKEN'
        }
    }
    return CSRF_COOKIE_NAME;
}

let CSRF_HEADER_NAME = null;
function getCsrfHeaderName(){
    if (CSRF_HEADER_NAME == null){
        CSRF_HEADER_NAME = $("meta[name='csrf_header_name']").attr("content");
        if (isBlank(CSRF_HEADER_NAME)){
            CSRF_HEADER_NAME = 'X-XSRF-TOKEN';
        }
    }
    return CSRF_HEADER_NAME;
}

